package com.honeycomb.article;

public class DataRef {
	
	private Long dataID = null;
	private int dataIndex;
	
	public DataRef(int index) {
		this.dataIndex = index;
	}
	
	public Long getDataID() {
		return dataID;
	}
	
	public void setDataID(Long dataID) {
		this.dataID = dataID;
	}
	
	public int getDataIndex() {
		return dataIndex;
	}
	
	/*
	public String encode() {
		return dataIndex +"," + (dataID == null ? " " : dataID.longValue());
	}
	
	public static DataRef decode(String str) {
		String[] elems = str.split(",");
		if (elems.length != 2) {
			throw new IllegalArgumentException("The encode string can not be recognized: " + str);
		}
		
		DataRef dataRef = null;
		try {
			dataRef = new DataRef(Integer.parseInt(elems[0]));
			if (!elems[1].equals(" ")) {
				dataRef.setDataID(Long.decode(elems[1]) );
			}
		}
		catch(Exception ex) {
			throw new IllegalArgumentException("The encode string can not be recognized: " + str);
		}
		
		return dataRef;
	}
	*/
	
	@Override
	public String toString() {
		return "[index=" + dataIndex + ", ID=" + dataID + "]";
	}
	
}

